package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.admin.biz.IndexBiz;
import com.cq.hd.admin.dto.ActiveDataTrendStatisticsDto;
import com.cq.hd.admin.dto.OrderDataTrendStatisticsDto;
import com.cq.hd.admin.vo.ActiveDataTrendStatisticsVo;
import com.cq.hd.admin.vo.IndexDataStatisticsVo;
import com.cq.hd.admin.vo.OrderDataTrendStatisticsVo;
import com.cq.hd.admin.vo.TodoDataVo;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "首页相关接口")
@Slf4j
@RestController
@RequestMapping("/index")
public class IndexController extends BaseController {

    @Autowired
    private IndexBiz indexBiz;

    // 总览（今日成交额，今日成交量，今日结算金额，今日结算佣金，今日提现佣金，今日新增用户数，今日新增商家数，今日新增商户数，今日新增经纪人数，累计发布活动数，本周上新活动数）
    @ApiOperation(value = "总览")
    @ApiResponse(response = IndexDataStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("index:statistics:data")
    @RequiresPermissionsDesc(menu = {"首页", "统计"}, button = "总览")
    @GetMapping("/dataStatistics")
    public Result<IndexDataStatisticsVo> dataStatistics() {
        return ResultGenerator.success(indexBiz.dataStatistics());
    }

    @ApiOperation(value = "成交统计")
    @ApiResponse(response = OrderDataTrendStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("index:statistics:orderDataTrend")
    @RequiresPermissionsDesc(menu = {"首页", "统计"}, button = "成交统计")
    @GetMapping("/orderDataTrendStatistics")
    public Result<List<OrderDataTrendStatisticsVo>> orderDataTrendStatistics(OrderDataTrendStatisticsDto orderDataTrendStatisticsDto) {
        return ResultGenerator.success(indexBiz.orderDataTrendStatistics(orderDataTrendStatisticsDto));
    }

    @ApiOperation(value = "活动发布统计")
    @ApiResponse(response = ActiveDataTrendStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("index:statistics:activeDataTrend")
    @RequiresPermissionsDesc(menu = {"首页", "统计"}, button = "活动发布统计")
    @GetMapping("/activeDataTrendStatistics")
    public Result<List<ActiveDataTrendStatisticsVo>> activeDataTrendStatistics(ActiveDataTrendStatisticsDto activeDataTrendStatisticsDto) {
        return ResultGenerator.success(indexBiz.activeDataTrendStatistics(activeDataTrendStatisticsDto));
    }

    @ApiOperation(value = "待办事项")
    @ApiResponse(response = TodoDataVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("index:statistics:toDoData")
    @RequiresPermissionsDesc(menu = {"首页", "统计"}, button = "待办事项")
    @GetMapping("/toDoDataStatistics")
    public Result<TodoDataVo> toDoDataStatistics() {
        return ResultGenerator.success(indexBiz.toDoDataStatistics());
    }

}
